package com.hyperboost.controller;

import com.hyperboost.constant.MessageConstant;
import com.hyperboost.dto.OpportunityCommentDTO;
import com.hyperboost.dto.OpportunityCommentPageQueryDTO;
import com.hyperboost.dto.OpportunityCommentReplyQueryDTO;
import com.hyperboost.result.PageResult;
import com.hyperboost.result.Result;
import com.hyperboost.service.OpportunityCommentService;
import com.hyperboost.vo.OpportunityCommentReplyVO;
import com.hyperboost.vo.OpportunityCommentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 机会评论相关接口
 */
@RestController
@RequestMapping("/frontend/opportunityComment")
public class OpportunityCommentController {

    @Autowired
    private OpportunityCommentService commentService;

    /**
     * 发布评论
     * @param commentDTO
     * @return
     */
    @PostMapping("/addComment")
    public Result addComment(@RequestBody OpportunityCommentDTO commentDTO){
        commentService.addComment(commentDTO);
        return Result.success(MessageConstant.ADD_COMMENT_SUCCESS);
    }

    /**
     * 删除评论
     *
     * @param commentId
     * @return
     */
    @DeleteMapping("/{commentId}")
    public Result deleteComment(@PathVariable Long commentId){
        commentService.deleteComment(commentId);
        return Result.success(MessageConstant.DELETE_COMMENT_SUCCESS);
    }
    /**
     * 分页展示顶级评论
     *
     * @param commentPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult<OpportunityCommentVO>> page(OpportunityCommentPageQueryDTO commentPageQueryDTO){
        return Result.success(commentService.pageQuery(commentPageQueryDTO));
    }

    /**
     * 展示回复评论列表
     *
     * @param commentReplyQueryDTO
     * @return
     */
    @GetMapping("/listReply")
    public Result<List<OpportunityCommentReplyVO>> listReply(OpportunityCommentReplyQueryDTO commentReplyQueryDTO){
        return Result.success(commentService.listReply(commentReplyQueryDTO));
    }
}
